<?php

namespace app\common\model;

use think\facade\Cache;
use think\Model;

class LotteryAwardModel extends Model
{
    const AWARD_TYPE = [
        '0' => '经验值',
        '1' => '金币',
        '2' => '龙钻',
        '3' => '礼物',
        '4' => '道具',
        '5' => '贵族体验卡',
        '6' => '免费抽奖'
    ];
    protected static function init()
    {
        static::afterUpdate(function ($user) {
            Cache::rm('lottery_award_list');
        });
        static::afterInsert(function ($user) {
            Cache::rm('lottery_award_list');
        });

        static::afterDelete(function ($user) {
            Cache::rm('lottery_award_list');
        });
    }

    public static function lists()
    {
        return Cache::remember('lottery_award_list', function () {
            return static::select()->toArray();
        });
    }
}
